# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

class BaseEvaluator:
    def __init__():
        pass

    def score(self):
        raise NotImplementedError()


class BaseRetrievalEvaluator(BaseEvaluator):
    def __init__(self, retrieval_result, **kwargs):
        """
        retrieval_result: list of tuple, (query_id_list, target_id_list, retrieval_result_dict)
        retrieval_result_dict: dict, {query_id: [[retrieval_target_id, score]]}  
        """
        self.retrieval_result = retrieval_result
        assert isinstance(self.retrieval_result, list)


class BaseClassificationEvaluator(BaseEvaluator):
    def __init__(self, y_truth, y_pred_proba, **kwargs):
        self.y_truth = y_truth
        self.y_pred_proba = y_pred_proba
        assert isinstance(self.y_truth, list)
        assert isinstance(self.y_pred_proba, list)
        assert len(self.y_truth) == len(self.y_pred_proba)
